﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.已开立看板.Service
{
    public class 已开立Service
    {
        /// <summary>
        /// 获取生产计划一览
        /// </summary>
        /// <returns></returns>
        public static List<DailyOrderLogDTO> getDailyOrderLogRecentMonth()
        {
            return
                FunctionHelper.JsonDeserialization<List<DailyOrderLogDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getDailyOrderLogRecentMonth"
                        )
                    );
        }
        /// <summary>
        /// 生产计划明细
        /// </summary>
        /// <param name="pmcDate"></param>
        /// <returns></returns>
        public static List<DailyOrderDTO> getDailyOrderByPmcDate(String pmcDate)
        {
            return
                FunctionHelper.JsonDeserialization<List<DailyOrderDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/pmc/getDailyOrderByPmcDate?pmcDate=" + pmcDate
                        )
                    );
        }
    }
    public class DailyOrderDTO
    {
        public String batchNo { get; set; }  //  生产批次号
        public DateTime batchDate { get; set; } //  生产批次开立时间
        public String batchStatus { get; set; } //  生产批状态 @See  top.toptimus.constValue.PMCLotStatus
        public Boolean urgentFlg { get; set; }  //  加急标识
        public Double batchQuantity { get; set; }   //  批次数量

        /**
         * 订单信息
         */
        public String orderId { get; set; }
        public String orderNo { get; set; } //  订单号
        public DateTime orderDate { get; set; } //  订单时间
        /**
         * 款式信息
         */
        public String styleId { get; set; }
        public String refStyleId { get; set; }  //  参考款id
        public String styleSizeCd { get; set; } //  尺码
        public String styleNameCn { get; set; } //  款式名称
        /**
         * 面料信息
         */
        public String styleFabricId { get; set; }//面料id
        public String materialNameCn { get; set; }//面料描述名称
        public String materialCode { get; set; }  //面料号
        public String composition { get; set; }//面料成分
        /**
         * 客户信息
         */
        public String customerName { get; set; }
        public String mobile { get; set; }
        public String addressDetail { get; set; }//详细地址
        public String zipCode { get; set; }//邮编
        public String customerCountId { get; set; }//客户量体id
        /**
         * 客户返单信息
         */
        public String refOrderId { get; set; }  //  客户返单id
        public String refOrderNo { get; set; }  //  客户返单号

        /**
         * 销售渠道信息
         * top.toptimus.dto.order.orderSync.orderCommit.OrderCommitDto#salesType赋值方式：
         * 1、top.toptimus.domainService.model.orderModel.OrderCacheModel#OrderCacheModel(top.toptimus.dto.store.OrderSalesConfirmationDTO, top.toptimus.dto.order.errorMessage.OrderIdAndStyleIdDTO, java.lang.String)
         * 销售确认逻辑赋值
         * 2、top.toptimus.domainService.service.rework.ReworkTransitionService#saveRework(java.lang.String, java.lang.String)
         * 重工赋值
         */
        public String salesType { get; set; }    //  销售方式    top.toptimus.constValue.SalesTypeConsts
        public String salesChannel { get; set; }    //  销售渠道,前台赋值。主要区分线上（微店）、线下（系统下单）、经销商、大货
        public String orderType { get; set; }
        public String remarks { get; set; }//备注
        public Boolean overDue { get; set; }    //  是否逾期
        public String overDueReason { get; set; }   //  逾期原因    TODO
        public Boolean duplicateOrderNo { get; set; }   //  重复订单号
        public Boolean saleNumberNotMatch { get; set; }   //  销售订单数量与生产订单数量不一致
        public Boolean batchNumberNotMatch { get; set; }  //   已开立生产批数量与生产订单数量不一致
        public DailyOrderDTO()
        {

        }
    }
    public class DailyOrderLogDTO
    {
        public String pmcDate { get; set; } //  生产计划日期
        public String memo { get; set; }    //  备注
        public DateTime createDate { get; set; }
        public DailyOrderLogDTO()
        {

        }
    }
    public class DailyOrderDisplayDTO
    {
        public String batchNo { get; set; }  //  生产批次号
        public DateTime batchDate { get; set; } //  生产批次开立时间
        public String batchStatus { get; set; } //  生产批状态 @See  top.toptimus.constValue.PMCLotStatus
        public String urgentFlg { get; set; }  //  加急标识
        public Double batchQuantity { get; set; }   //  批次数量

        /**
         * 订单信息
         */
        public String orderId { get; set; }
        public String orderNo { get; set; } //  订单号
        public DateTime orderDate { get; set; } //  订单时间
        /**
         * 款式信息
         */
        public String styleId { get; set; }
        public String refStyleId { get; set; }  //  参考款id
        public String styleSizeCd { get; set; } //  尺码
        public String styleNameCn { get; set; } //  款式名称
        /**
         * 面料信息
         */
        public String styleFabricId { get; set; }//面料id
        public String materialNameCn { get; set; }//面料描述名称
        public String materialCode { get; set; }  //面料号
        public String composition { get; set; }//面料成分
        /**
         * 客户信息
         */
        public String customerName { get; set; }
        public String mobile { get; set; }
        public String addressDetail { get; set; }//详细地址
        public String zipCode { get; set; }//邮编
        public String customerCountId { get; set; }//客户量体id
        /**
         * 客户返单信息
         */
        public String refOrderId { get; set; }  //  客户返单id
        public String refOrderNo { get; set; }  //  客户返单号

        /**
         * 销售渠道信息
         * top.toptimus.dto.order.orderSync.orderCommit.OrderCommitDto#salesType赋值方式：
         * 1、top.toptimus.domainService.model.orderModel.OrderCacheModel#OrderCacheModel(top.toptimus.dto.store.OrderSalesConfirmationDTO, top.toptimus.dto.order.errorMessage.OrderIdAndStyleIdDTO, java.lang.String)
         * 销售确认逻辑赋值
         * 2、top.toptimus.domainService.service.rework.ReworkTransitionService#saveRework(java.lang.String, java.lang.String)
         * 重工赋值
         */
        public String salesType { get; set; }    //  销售方式    top.toptimus.constValue.SalesTypeConsts
        public String salesChannel { get; set; }    //  销售渠道,前台赋值。主要区分线上（微店）、线下（系统下单）、经销商、大货
        public String orderType { get; set; }
        public String remarks { get; set; }//备注
        public String overDue { get; set; }    //  是否逾期
        public String overDueReason { get; set; }
        public String styleInfo { get; set; }    //  款式信息
        public String customerInfo { get; set; }//客户信息
        public String duplicateOrderNo { get; set; }   //  重复订单号
        public String saleNumberNotMatch { get; set; }   //  销售订单数量与生产订单数量不一致
        public String batchNumberNotMatch { get; set; }  //   已开立生产批数量与生产订单数量不一致
        public DailyOrderDisplayDTO(DailyOrderDTO dailyOrderDTO)
        {
            this.orderNo = dailyOrderDTO.orderNo;
            this.orderDate = dailyOrderDTO.orderDate;
            this.batchNo = dailyOrderDTO.batchNo;
            this.batchDate = dailyOrderDTO.batchDate;
            this.batchStatus = dailyOrderDTO.batchStatus;
            this.urgentFlg = dailyOrderDTO.urgentFlg?"加急":"正常";
            this.overDue = dailyOrderDTO.overDue ? "否" : "是";
            this.styleInfo = dailyOrderDTO.styleNameCn + "\n"
                + dailyOrderDTO.materialNameCn + "\n"
                + dailyOrderDTO.composition;
            this.materialCode = dailyOrderDTO.materialCode;
            this.batchQuantity = dailyOrderDTO.batchQuantity;
            this.styleSizeCd = dailyOrderDTO.styleSizeCd;
            this.customerInfo = dailyOrderDTO.customerName + "\n"
                + dailyOrderDTO.mobile + "\n"
                + dailyOrderDTO.addressDetail;
            this.salesType = dailyOrderDTO.salesType;
            this.salesChannel = dailyOrderDTO.salesChannel;
            this.remarks = dailyOrderDTO.remarks;
            this.duplicateOrderNo = dailyOrderDTO.duplicateOrderNo ? "是" : "否";
            this.saleNumberNotMatch = dailyOrderDTO.saleNumberNotMatch ? "不一致" : "一致";
            this.batchNumberNotMatch = dailyOrderDTO.batchNumberNotMatch ? "不一致" : "一致";
        }
    }

}
